<?php
/**
 * XmlRpc解码关联数组
 *
 * @version $Id: XmlRpcStructDecoder.php 312 2008-04-23 16:29:38Z iwind $
 * @package net.4kiki.rai.format.xmlrpc.decoder
 * @since 0.0.3
 */
class XmlRpcStructDecoder extends AbstractXmlRpcDecoder {
	public function getValue() {
		$dom = new DOMDocument("1.0", $this->getCharset());
		$dom->loadXml($this->getXml());
		$xpath = new DOMXPath($dom);
		$memberNodes = $xpath->query("/struct/member");
		$array = array();
		if ($memberNodes->length > 0) {
			foreach ($memberNodes as $memberNode) {
				$nameNode = $xpath->query("name", $memberNode)->item(0);
				$valueTypeNode = $xpath->query("value/*", $memberNode)->item(0);
				if ($valueTypeNode != null) {
					$valueXml = $dom->saveXml($valueTypeNode);
					$array[$nameNode->nodeValue] = XmlRpcHelper::getDecoder($valueTypeNode->nodeName, $valueXml, $this->getCharset())->getValue();
				}
			}
		}
		return $array;
	}
}

?>